<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
   
    let caishuzi=(m,n)=>{
     let num1= Math.floor(Math.random()*(m-n+1))+n
     let i=1
 while(true){
   let num = +prompt('猜数字啦')
   
   if (num === num1) {
     alert('恭喜猜对')
     break;
   } else if (num < num1) {
     if (i >=8) {
       alert('这都猜不对')
       break
     }
     alert('你猜的数字小了')
     i++
    
   } else {
     if (i >= 8) {
       alert('这都猜不对')
       break
     }
     alert('你猜的数字大了')
     i++
   }
 }
 }  
    caishuzi(1,10)
  </script>
</body>
</html>